package com.fengling.common.config;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.fengling.common.interceptors.UserInfoInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

  // 若想生效 需要被启动类spring包扫描到 由于其他微服务扫描不到 需要去文件里手动添加该配置类来表示该配置类需要被扫描
@Configuration
@ConditionalOnClass({DispatcherServlet.class})   // spring自动装配的条件（避免在不是mvc框架里的网关生效）
public class SpringMVCConfig implements WebMvcConfigurer {
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
          // 添加拦截器
          registry.addInterceptor(new UserInfoInterceptor());
      }

}
